#ifndef _XP_LOG_H
#define _XP_LOG_H

#include "cli_cmd.h"

#define LOG_LEVEL_NULL      (-1)
#define LOG_LEVEL_ERROR     (0)
#define LOG_LEVEL_WARN      (1)
#define LOG_LEVEL_INFO      (2)
#define LOG_LEVEL_DEBUG     (3)

// 设定日志级别
#define PRINT_LOG_LEVEL     LOG_LEVEL_DEBUG

#define XLOG_FILE (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)

#if (PRINT_LOG_LEVEL >= LOG_LEVEL_ERROR)
#define xlog_error(format, args...) printo(" [%s:%d] [error] "format"\n", XLOG_FILE, __LINE__, ##args)
#else
#define xlog_error(format, args...) do{}while(0)
#endif

#if (PRINT_LOG_LEVEL >= LOG_LEVEL_WARN)
#define xlog_warn(format, args...) printo(" [%s:%d] [warn] "format"\n", XLOG_FILE, __LINE__, ##args)
#else
#define xlog_warn(format, args...) do{}while(0)
#endif

#if (PRINT_LOG_LEVEL >= LOG_LEVEL_INFO)
#define xlog_info(format, args...) printo(" [%s:%d] [info] "format"\n", XLOG_FILE, __LINE__, ##args)
#else
#define xlog_info(format, args...) do{}while(0)
#endif

#if (PRINT_LOG_LEVEL >= LOG_LEVEL_DEBUG)
#define xlog_debug(format, args...) printo(" [%s:%d] [debug] "format"\n", XLOG_FILE, __LINE__, ##args)
#else
#define xlog_debug(format, args...) do{}while(0)
#endif

#endif
